﻿#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
class MinStack {
public:
    MinStack() {

    }

    void push(int val) {
        q.push(val);
        if (min.empty() || val<=min.top())
            min.push(val);
    }

    void pop() {
        if (q.top() == min.top())
            min.pop();
        q.pop();
    }

    int top() {
        return q.top();
    }

    int getMin() {
        return min.top();
    }
    stack<int> q;
    stack<int> min;
};

//最小栈
//https://leetcode.cn/problems/min-stack/
class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param pushV int整型vector
     * @param popV int整型vector
     * @return bool布尔型
     */
    bool IsPopOrder(vector<int>& pushV, vector<int>& popV) {
        // write code here
        stack<int> q;
        int i = 0;
        int j = 0;
        
        while (i < pushV.size())
        {
            q.push(pushV[i]);
            while (!(q.empty()) && q.top() == popV[j]) //模拟出栈入栈
            {
                q.pop();;
                j++;
            }
            i++;
        }
        return q.empty();
    }
};


